/**
 * 
 */
package riot.challenge.java.achievements;

import java.util.ArrayList;
import java.util.List;

import riot.challenge.java.interfaces.IAchievementsManager;
import riot.challenge.java.interfaces.IAchievement;
import riot.challenge.java.interfaces.IHistoricalPlayerStatistics;
import riot.challenge.java.interfaces.IPlayerGameStatistics;
import riot.challenge.java.interfaces.IStatistics;

/**
 * @author Dams
 * 
 */
public class AchievementsManager implements IAchievementsManager {

	private List<IAchievement> achievementList;

	private static AchievementsManager instance;

	private AchievementsManager() {

		this.achievementList = new ArrayList<IAchievement>();
	}

	public AchievementsManager getInstance() {

		if (instance == null)
			instance = new AchievementsManager();

		return instance;
	}

	private void loadAchievements() {

		// TODO !

	}

	public List<IAchievement> getValidAchievements(IStatistics stats) {

		List<IAchievement> resultList = new ArrayList<IAchievement>();

		for (IAchievement achievement : achievementList) {

			if ((achievement.isUnique() && (stats instanceof IHistoricalPlayerStatistics))
					|| (stats instanceof IPlayerGameStatistics)) {

				if (achievement.isAchieve(stats))
					resultList.add(achievement);
			}
		}

		return resultList;
	}
}
